From: Florian Müllner Date: Tue, 21 Nov 2023 12:28:30 +0000 (+0100) Subject: dbusServices/extensions: Only show dialog when loaded X-Git-Tag: archive/raspbian/50.5-1+rpi1~1^2~281^2~2^2~280 X-Git-Url: https://dgit.raspbian.org/%22http://www.example.com/cgi/%22/%22http:/www.example.com/cgi/%22?a=commitdiff_plain;h=7f7ae31fa38d03fb64e0c29717a88c6edf420096;p=gnome-shell.git dbusServices/extensions: Only show dialog when loaded After the port to ESM, an extension's `prefs.js` file is imported asynchronously. An unintended side effect of that is that we now show the dialog before anything can be added to the window (either by the extension, or the fallback error UI). The delay almost always won't be noticeable to users, but it's bad practice and prevents extensions from using some API that only works before the window is realized. To address the issue, add a `loaded` signal to the dialog that allows the caller to postpone showing the window until the UI is ready. Close: https://gitlab.gnome.org/GNOME/gnome-shell/-/issues/7201 Part-of: --- diff --git a/js/dbusServices/extensions/extensionPrefsDialog.js b/js/dbusServices/extensions/extensionPrefsDialog.js index 6c1b5d508..50b2e92f5 100644 --- a/js/dbusServices/extensions/extensionPrefsDialog.js +++ b/js/dbusServices/extensions/extensionPrefsDialog.js @@ -9,6 +9,9 @@ import Gtk from 'gi://Gtk?version=4.0'; export const ExtensionPrefsDialog = GObject.registerClass({ GTypeName: 'ExtensionPrefsDialog', + Signals: { + 'loaded': {}, + }, }, class ExtensionPrefsDialog extends Adw.PreferencesWindow { _init(extension) { super._init({ @@ -21,7 +24,7 @@ export const ExtensionPrefsDialog = GObject.registerClass({ this._loadPrefs().catch(e => { this._showErrorPage(e); logError(e, 'Failed to open preferences'); - }); + }).finally(() => this.emit('loaded')); } async _loadPrefs() { diff --git a/js/dbusServices/extensions/extensionsService.js b/js/dbusServices/extensions/extensionsService.js index 0d60fb60e..f3f8f4156 100644 --- a/js/dbusServices/extensions/extensionsService.js +++ b/js/dbusServices/extensions/extensionsService.js @@ -137,6 +137,8 @@ export const ExtensionsService = class extends ServiceImplementation { const extension = extensionManager.createExtensionObject(serialized); this._prefsDialog = new ExtensionPrefsDialog(extension); + this._prefsDialog.connect('loaded', + () => this._prefsDialog.show()); this._prefsDialog.connect('realize', () => { let externalWindow = null; @@ -157,8 +159,6 @@ export const ExtensionsService = class extends ServiceImplementation { }); this.hold(); - this._prefsDialog.show(); - invocation.return_value(null); } catch (error) { this._handleError(invocation, error);